﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace eDoc.Controls.DownloadCounter
{
    public partial class ucEdit : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }

        private void BindData()
        {
            DataTable dt = new DataTable();
            dt = BO.Data.Select_DownloadCounter(BO.Common.PartnerCode);
            if (dt != null && dt.Rows.Count > 0)
            {
                txtCounter.Text= dt.Rows[0]["counter"].ToString();
                txtCounterLimit.Text = dt.Rows[0]["CounterLimit"].ToString();
                txtPartnerCode.Text = BO.Common.PartnerCode;
                btUpdate.Visible = true;
            }
            else
            {
                btUpdate.Visible = false;
            }
        }

        protected void btUpdate_Click(object sender, EventArgs e)
        {
            
            BO.Data.Update_DownloadCounter(BO.Common.PartnerCode, Convert.ToInt32(txtCounter.Text.Trim()), Convert.ToInt32(txtCounterLimit.Text.Trim()));
            lblNote.Text = "Cập nhật thành công!";
        }
    }
}